<template>
  <div>
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>表四 - 标签配线表
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(-1)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe606;</span>返回
          </el-button>
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>
    <div class="component-searchHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">标签配线</p>
          <div class="right"></div>
        </div>
      </div>
    </div>
    <div class="table">
      <div class="title">{{tableTitle}}</div>
      <el-table
        ref="multipleTable"
        :data="info"
        tooltip-effect="dark"
        style="width:100%"
        border
      >
        <el-table-column width="180" align="center" prop="col_1">
          <template slot="header" slot-scope="scope">
            {{tableHeader.col_1}}
          </template>
        </el-table-column>
        <el-table-column width="180" align="center" prop="col_2">
          <template slot="header" slot-scope="scope">
            {{tableHeader.col_2}}
          </template>
        </el-table-column>
        <el-table-column align="center" width="180" prop="rowCode">
          <template slot="header" slot-scope="scope">
            {{tableHeader.col_3}}
          </template>
        </el-table-column>
        <el-table-column align="center" width="180" prop="col_4">
          <template slot="header" slot-scope="scope">
            {{tableHeader.col_4}}
          </template>
        </el-table-column>
        <el-table-column align="center" width="180" prop="col_5">
          <template slot="header" slot-scope="scope">
            {{tableHeader.col_5}}
          </template>
        </el-table-column>
        <el-table-column align="center" width="180" prop="col_6">
          <template slot="header" slot-scope="scope">
            {{tableHeader.col_6}}
          </template>
        </el-table-column>
        <el-table-column label="松套管" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?scope.row.webSgt:'蓝'}}
          </template>
        </el-table-column>
        <el-table-column label="1" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'蓝'}}
          </template>
        </el-table-column>
        <el-table-column label="2" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'橙'}}
          </template>
        </el-table-column>
        <el-table-column label="3" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'绿'}}
          </template>
        </el-table-column>
        <el-table-column label="4" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'棕'}}
          </template>
        </el-table-column>
        <el-table-column label="5" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'灰'}}
          </template>
        </el-table-column>
        <el-table-column label="6" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'白'}}
          </template>
        </el-table-column>
        <el-table-column label="松套管" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'蓝'}}
          </template>
        </el-table-column>
        <el-table-column label="7" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'蓝'}}
          </template>
        </el-table-column>
        <el-table-column label="8" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'橙'}}
          </template>
        </el-table-column>
        <el-table-column label="9" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'绿'}}
          </template>
        </el-table-column>
        <el-table-column label="10" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'棕'}}
          </template>
        </el-table-column>
        <el-table-column label="11" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'灰'}}
          </template>
        </el-table-column>
        <el-table-column label="12" align="center" width="80" prop="">
          <template slot-scope="scope">
            {{scope.row.webSgt?'':'白'}}
          </template>
        </el-table-column>
        <el-table-column label="备注" align="center" width="180" prop="col_over"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        info:[],
        tableTitle:"",
        tableHeader:{},
        infoIndex:0,
      };
    },
    created(){

    },
    mounted(){
      console.log(this.$route.query.proId)
      this.dataInit();
    },
    methods: {
      dataInit(){
        let arr = [
                {rowCode:'a',col_4:'前期占用'},
                {rowCode:'b',col_4:'前期占用'},
                {rowCode:'c',col_4:'前期占用'},
                {rowCode:'d',col_4:'前期占用'},
                {rowCode:'e',col_4:'前期占用'},
                {rowCode:'f',col_4:'前期占用'},
                {rowCode:'g',col_4:'前期占用'},

                {rowCode:'h',col_4:'前期占用'},
                {rowCode:'i',col_4:'前期占用'},
                {rowCode:'j',col_4:'前期占用'},
                {rowCode:'k',col_4:'前期占用'},
                {rowCode:'l',col_4:'前期占用'},
                {rowCode:'m',col_4:'前期占用'},
                {rowCode:'n',col_4:'前期占用'}, 

                {rowCode:'o',col_4:'前期占用'},
                {rowCode:'p',col_4:'前期占用'},
                {rowCode:'q',col_4:'前期占用'},
                {rowCode:'r',col_4:'前期占用'},
                {rowCode:'s',col_4:'前期占用'},
                {rowCode:'t',col_4:'前期占用'},

                {rowCode:'u',col_4:'前期占用'},
                {rowCode:'v',col_4:'前期占用'},
                {rowCode:'w',col_4:'前期占用'},
                {rowCode:'x',col_4:'前期占用'},
                {rowCode:'y',col_4:'前期占用'}, 
                {rowCode:'z',col_4:'前期占用'},
              ];
        let that = this,
          suCb = function (res) {
            console.log(res)
            that.tableTitle = res.data.title;
            that.tableHeader = res.data.header;
            // 对返回结果进行排序
            res.data.data.sort((a,b) => {
              return a.rowCode - b.rowCode
            });
            // 替换rowcode相当的项
            res.data.data.forEach(item => {
              arr.forEach((item1,index) => {
                if(item.rowCode == item1.rowCode){
                  arr[index] = item;
                  that.infoIndex = index;
                }
              })
            })
            console.log(that.infoIndex)
            // 把最后一项之后替换成空闲
            for(let i=that.infoIndex+1;i<res.data.col_total;i++){
              arr[i].col_4 = "";
              arr[i].webSgt = "空闲";
            };
            console.log(arr)
            // 删除总数之外的行数
            that.info = arr.slice(0,res.data.col_total)

            console.log(that.info)
          },
          erCb = function (res) {
            console.log(res)
          },
          palyParam = {
            url: "/api/web/proProject/getLaberWiring",
            methods: 'post',
            data: {
              // proId: "f22cc076-a30a-44f2-8522-86722041"
              proId : that.$route.query.proId
            },
            success: suCb,
            error: erCb,
          }
        that.$https(palyParam)
      },
    },
    watch: {}

  };
</script>
<style scoped>
  .component-mainHeader .top .topright {
    font-size: 24px;
  }

  .component-searchHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
  }

  .component-searchHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-searchHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    line-height: 45px;
    text-align: left;
    margin: 0 0 0 30px;
  }
  .table>div.title{
    border-left:1px solid #e4e4e4;
    border-right:1px solid #e4e4e4;
    height: 45px;
    line-height: 45px;
  }
  .table{
    width: 1100px;
    margin: 0px auto;
    border-top:none;
  }
</style>
